Skip to main content

runWithProvider

method definition

runWithProvider( provider: Partial<ITxRunnerProvider> ): TxBuilderRunner

given a Partial<ITxRunnerProvider> returns a TxBuilderRunner

The empty provider

Partial implies that none of the methods specified in ITxRunnerProvider are really required.

a TxBuilderRunner instance will do its best to minimize calls to the provider; that means that if all the data needed is already present (as in the case of the buildSync method) the provider is not needed.

so an empty object ({}) is a valid provider.

Pro and Cons of the empty provider

The advantage of using runWithProvider with an empty provider over using directly buildSync is an even higher level interface to build transaction, which might turn useful for complex transactions.

The disadvantages are that the TxBuilderRunner methods might throw an error if some data that needs to be resolved (e.g. datum hashes or utxo references) is not present;

so you will have to make sure you resolve your utxos and datums.